package com.coffee.test;

import com.coffee.netty.connection.Connection;
import com.coffee.netty.connection.ConnectionCommandHandler;
import com.coffee.test.util.NotifyProxy;
import io.netty.channel.ChannelHandlerContext;

/**
 * @author songkui
 * @since 2024/8/7 11:52
 */
public class HjCommandHandler implements ConnectionCommandHandler {
    @Override
    public void handleCommand(ChannelHandlerContext ctx, Object msg) throws Exception {
        Connection connection = Connection.getByChannel(ctx.channel());
        System.out.println("process command message"+ (null != connection ? connection : "connect is null;") +" "+msg);
        if ("222".equals(msg)){
            System.out.println("---put xxxx---");
            NotifyProxy.notifyProxy.ackSyncMsg(ctx.channel(), (String) msg);
        }
    }

    @Override
    public void channelInactive(ChannelHandlerContext ctx) throws Exception {
        Connection connection = Connection.getByChannel(ctx.channel());
        System.out.println("process channelInactive message"+ (null != connection ? connection : "connect is null;"));
    }

    @Override
    public void initialConnect(Connection connection) {
        System.out.println("process initialConnect  message" + connection);
    }

    @Override
    public void disconnectReconnect(Connection connection) {
        System.out.println("process disconnectReconnect  message" + connection);
    }
}
